package controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import pojo.DevUser;
import service.Userservice;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * Created by dell on 2019/1/14.
 */
@Controller
@RequestMapping("User")
public class Usercontroller {
    @Resource
    public Userservice userservice;
    @RequestMapping("/login")
    public String shou(){



        return    "login";
    }
    //登录
    @RequestMapping("/dl")
    public  String login(@RequestParam(value = "devName",required = false) String devName,
                         @RequestParam(value = "devPassword",required = false) String devPassword,
                         @RequestParam(value = "devCode",required = false) String devCode,
                                                                         HttpSession session){
        DevUser devUser=new DevUser();
        devUser=userservice.login(devName,devPassword,devCode);
//全查到用户存到session
//
//    devUser=   userservice.allselect(devName);
        session.setAttribute("User",devUser);
        if(devUser!=null){

            return "index";

        }else {

            return  "login";
        }

    }
   @RequestMapping("zx")
    public  String ZX(HttpSession session){
       session.removeAttribute("User");

        return  "index";
   }

}

